<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="app">
        <input type="text" placeholder="输入数字" v-model="count">
        <h1>{{getNum}}</h1>
        <button @click="handclick">更改</button>
    </div>
</body>

</html>
<script src="./vue-2.5.21.js"></script>
<script>
    var v = new Vue({
        el: '.app',
        data: {
            count: 0
        },
        methods: {
            handclick() {
                this.getNum = 1000
            }
        },
        computed: {
            // getNum(){
            //     var res=0
            //     for(var i=0;i<=this.count;i++){
            //         res+=i
            //     }
            //     return res
            // }
            getNum: {
                get() {
                    var res = 0
                    for (var i = 0; i <= this.count; i++) {
                        res += i
                    }
                    return res
                },
                set(value){
                    console.log(value);
                }
            }
        }

    })
</script>